﻿function getTime() {
    $.getJSON("current", function(data) {
        updateData($("#second"), data.second, getTime());
        updateData($("#minute"), data.minute);
        updateData($("#hour"), data.hour);
        updateData($("#date"), data.date);
        updateData($("#tt"), data.tt);
    });
}

function updateData(tag, data, callback) {
    if (tag.html() == data || tag.attr("id") == "second") {
        tag.html (data);
        if (null != callback)
            callback();
    } else {
        tag.fadeOut ("slow", function () {
            tag.html (data);
            tag.fadeIn ("slow", callback);
        });
    }
}

$(window).load(function(){
    $("#content").fadeIn("slow", function(){
        $("#time").show("slow", getTime());
    });
});